<template>
	<view>
		<view class="team_box">
			<view class="team_list" v-for="(item,index) in data" :key="index" v-if="total > 0">
				<view class="team_list_left">
					<u-avatar :src="item.avatar" default-url="/static/default.jpg" size="55" shape="square"></u-avatar>
				</view>
				<view class="team_list_right">
					<view class="team_list_tit">
						<view>
							<text style="font-weight: bold;">{{item.name}}</text>
							<text style="margin-left: 16rpx; color: #82848a;" @click="phoneClick(item.mobile)">{{item.mobile}}</text>
						</view>
						<view>
							<text class="inventory_total">{{item.total.total}}</text>
						</view>
					</view>
					<view class="list">
						<view>
							<text class="active">已激活：</text>
							<u--text size="14" color="#19be6b" bold :text="item.total.activeNum"></u--text>
						</view>
						<view>
							<text class="noactive">未激活：</text>
							<u--text size="14" color="#fa3534" bold :text="item.total.noactiveNum"></u--text>
						</view>
					</view>
				</view>
			</view>
			<u-empty v-else mode="list" icon="/static/Empty/data_null.png">
			</u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
				bottom: true,
				page: 1,
				total: 0,
				product_id: null,
			}
		},
		onLoad(e) {
			this.product_id = e.id
			uni.setNavigationBarTitle({
				title: e.name + ' - 代理'
			})
			this._list()
		},
		//下拉刷新
		onReachBottom() {
			if (this.bottom == true) {
				this.page += 1
				this._list()
			}
		},
		methods: {
			// 团队列表
			async _list() {
				uni.showLoading({
					title: '加载中'
				});
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp5({
					url: 'Terminal/getProductSales',
					data: {
						product_id: this.product_id,
						page: this.page,
						page_size: 15
					},
					header: {
						'token': userinfo.token
					}
				});
				if (res.code == 1) {
					if (res.data !== undefined && res.data !== null && res.data.length >
						0) {
						if (this.page == 1) {
							this.total = res.data.length
							this.data = res.data
							uni.hideLoading()
						} else {
							this.data = [...this.data, ...res.data]
							uni.hideLoading()
						}
					} else {
						uni.hideLoading()
						this.bottom = false
					}
				} else {
					uni.showToast({
						title: res.msg,
						duration: 1000,
						icon: "none"
					});
					this.bottom = false
				}
			},
			info() {
				uni.navigateTo({
					url: '/pages/version5/data/team/team_info'
				})
			},
			phoneClick(tel) {
				uni.makePhoneCall({
					phoneNumber: tel
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.team_box {
		.team_tit {
			padding: 50rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			background: url(/static/team_bg.jpg) no-repeat center;

			text {
				font-size: 28rpx;
				color: #dbe6ff;
			}

			h2 {
				font-size: 52rpx;
				font-weight: 500;
				margin: 30rpx 0;
				color: #fff;
			}

			.tit {
				display: flex;
				justify-content: space-between;
				align-items: center;
				width:85%;
				margin-top: 30rpx;
			
			}

			h5 {
				color: #fff;
				font-size: 32rpx;
				text-align: center;
				margin-bottom: 10rpx;
				
			}
		}

		.team_list {
			padding: 30rpx;
			margin: 30rpx 0;
			display: flex;
			box-shadow: 7px 0px 30px -18px #888888;
			
			.team_list_left {
				width: 20%;
				align-items: center;
			}
			
			.team_list_right {
				width: 80%;
				.team_list_tit {
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding-bottom: 12rpx;
					border-bottom: #eee solid 1px;
				
					text {
						font-size: 28rpx;
					}
					
					.inventory {
						font-size: 24rpx;
					}
					
					.inventory_total {
						color: #fa3534;
						font-weight: bold;
						font-size: 32rpx;
					}
				}
				
				.list {
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding-top: 10rpx;
					
					view {
						display: flex;
						
						view {
							margin-right: 5rpx; padding-top: 5rpx;
						}
					}

					text {
						font-size: 28rpx;
					}
					
					.active {
						font-size: 24rpx;
						color: #19be6b;
						line-height: 44rpx;
						padding-top: 4rpx;
					}
					
					.noactive {
						font-size: 24rpx;
						color: #fa3534;
						line-height: 44rpx;
						padding-top: 4rpx;
					}
				}
			}
		}
	}
</style>
